package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.Movie;
import model.MovieCategory;

/**
 * Servlet implementation class MovieCriteriaSearch
 */
@WebServlet("/MovieCriteriaSearch")
public class MovieCriteriaSearchServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public MovieCriteriaSearchServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		services.ServiceProxy proxy = new services.ServiceProxy();
		proxy.setEndpoint("http://localhost:8080/videolibrary/services/Service?wsdl");
		String movieName = request.getParameter("movieName");
		String productionName = request.getParameter("productionName");
		String releaseDate = request.getParameter("releaseDate");
		int categoryId = Integer.parseInt(request.getParameter("category"));
		int availableCopies = Integer.parseInt(request.getParameter("Available Copies"));
		Movie movie = new Movie();
		MovieCategory moviecategory = new MovieCategory();
		moviecategory.setMovieCategoryId(categoryId);
		movie.setAvailableCopies(availableCopies);
		movie.setMovieName(movieName);
		movie.setProdBanner(movieName);
		movie.setReleaseDate(releaseDate);
		movie.setMovieCategory(moviecategory);
		Movie[] movieList = proxy.movieCriteriaSearch(movie);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
